import request from '@/utils/request'

export const permissionAPI = {
  // 获取所有权限
  getAllPermissions: () => {
    return request.get('/permissions')
  },

  // 根据角色ID获取权限
  getPermissionsByRoleId: (roleId) => {
    return request.get(`/permissions/role/${roleId}`)
  },

  // 根据用户ID获取权限
  getPermissionsByUserId: (userId) => {
    return request.get(`/permissions/user/${userId}`)
  },

  // 创建权限
  createPermission: (data) => {
    return request.post('/permissions', data)
  },

  // 更新权限
  updatePermission: (data) => {
    return request.put('/permissions', data)
  },

  // 删除权限
  deletePermission: (id) => {
    return request.delete(`/permissions/${id}`)
  }
}